package com.idata.controller;

import com.idata.common.constant.Result;
import com.idata.model.request.SearchRequest;
import com.idata.model.response.CitizenSearchResponse;
import com.idata.model.response.PageResult;
import com.idata.service.services.AssociationQueryManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @File AssociatingQueryController.Java
 * @Modify Time      @Author    @Version    @Description
 * ------------      -------    --------    -----------
 * 2023/9/22         yd.j      1.0         None
 */
@RestController
@RequestMapping("/home")
public class AssociatingQueryController {

    @Autowired
    private AssociationQueryManager queryServer;

    @PostMapping("/search")
    @ResponseBody
    public Result<PageResult<CitizenSearchResponse>> search(@RequestBody SearchRequest searchRequest) {
        PageResult<CitizenSearchResponse> res = queryServer.search(searchRequest);
        return Result.success(res);
    }

    @PostMapping("/relatedCitizen")
    @ResponseBody
    public Result<List<CitizenSearchResponse>> relatedCitizen(@RequestBody SearchRequest searchRequest) {
        List<CitizenSearchResponse> res = queryServer.relatedCitizen(searchRequest);
        return Result.success(res);
    }


}
